<?php


namespace App\Models;


class LessonTest extends Model
{
    protected $table = 'lesson_tests';

    // ============= relations ==========
    public function template()
    {
        $this->hasOne(TestTemplate::class, 'template_id');
    }

    // ============= scope ==========
    public function scopeOfType($query, $type)
    {
        return $query->where('type', $type);
    }

    // ============= field ==========
    public function setName($name)
    {
        $this->name = $name;
    }

    public function getName()
    {
        return $this->name;
    }

    public function setDescription($description)
    {
        $this->description = $description;
    }

    public function getDescription()
    {
        return $this->description;
    }

    public function setContent($content)
    {
        $this->content = json_encode($content);
    }

    public function getContent()
    {
        return json_decode($this->content, true);
    }

    public function setLessonId($lessonId)
    {
        $this->lesson_id = $lessonId;
    }

    public function setTemplateId($templateId)
    {
        $this->template_id = $templateId;
    }

    public function getTemplateId()
    {
        return (int)$this->template_id;
    }

    public function setLevelId($levelId)
    {
        $this->level_id = $levelId;
    }

    public function getLevelId()
    {
        return $this->level_id;
    }


    public function setSequence($sequence)
    {
        $this->sequence = $sequence;
    }

    public function setKnowledgeId($knowledgeId)
    {
        $this->knwoledge_id = $knowledgeId;
    }

}